<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** 
<span class='line'>  2</span>  * ドライブの存在チェックを行った上で、ドライブオブジェクトを作成します。
<span class='line'>  3</span>  * @class ドライブの操作を行うためのクラスです。
<span class='line'>  4</span> &lt;pre class = "code">
<span class='line'>  5</span> 使用例：
<span class='line'>  6</span> // Cドライブの空き容量を表示
<span class='line'>  7</span> var d = new Drive("c:");
<span class='line'>  8</span> print(d.getFreeSpace());
<span class='line'>  9</span> &lt;/pre>
<span class='line'> 10</span>  * @param  {String} path ディレクトリのパスを文字列で指定します。
<span class='line'> 11</span>  * @throws ディレクトリが存在しない場合にスローされます。
<span class='line'> 12</span>  */</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Drive</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">Drive.exist</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"Drive "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" not found."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT">  </span><span class="NAME">this.path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT">  </span><span class="NAME">this.driveObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Const.FSO.GetDrive</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 20</span> 
<span class='line'> 21</span> </span><span class="COMM">/**
<span class='line'> 22</span>  * ドライブタイプの定数：不明(0)
<span class='line'> 23</span>  */</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="NAME">Drive.DRIVE_TYPE_UNKNOWN</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 25</span> 
<span class='line'> 26</span> </span><span class="COMM">/**
<span class='line'> 27</span>  * ドライブタイプの定数：リムーバブルディスク(1)
<span class='line'> 28</span>  */</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="NAME">Drive.DRIVE_TYPE_REMOVABLE_DISK</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 30</span> 
<span class='line'> 31</span> </span><span class="COMM">/**
<span class='line'> 32</span>  * ドライブタイプの定数：ハードディスク(2)
<span class='line'> 33</span>  */</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="NAME">Drive.DRIVE_TYPE_HARD_DISK</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 35</span> 
<span class='line'> 36</span> </span><span class="COMM">/**
<span class='line'> 37</span>  * ドライブタイプの定数：ネットワークドライブ(3)
<span class='line'> 38</span>  */</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="NAME">Drive.DRIVE_TYPE_NETWORK_DRIVE</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> 
<span class='line'> 41</span> </span><span class="COMM">/**
<span class='line'> 42</span>  * ドライブタイプの定数：CD-ROM(4)
<span class='line'> 43</span>  */</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="NAME">Drive.DRIVE_TYPE_CDROM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> 
<span class='line'> 46</span> </span><span class="COMM">/**
<span class='line'> 47</span>  * ドライブタイプの定数：RAMディスク(5)
<span class='line'> 48</span>  */</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="NAME">Drive.DRIVE_TYPE_RAM_DISK</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> 
<span class='line'> 51</span> </span><span class="COMM">/**
<span class='line'> 52</span>  * ドライブの一覧を取得します。
<span class='line'> 53</span>  * @return {Array} Driveオブジェクトの配列
<span class='line'> 54</span>  */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="NAME">Drive.getDrives</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">Const.FSO.Drives</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">e.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">e.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="NAME">result.push</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Drive</span><span class="PUNC">(</span><span class="NAME">e.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">Path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 62</span> 
<span class='line'> 63</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> 
<span class='line'> 66</span> </span><span class="COMM">/**
<span class='line'> 67</span>  * pathで与えられたドライブが存在するかどうかをチェックします。
<span class='line'> 68</span>  * @param {String} path ドライブのパスを文字列で指定します。
<span class='line'> 69</span>  * @return {Boolean} 存在する場合はtrue、存在しない場合はfalseを返します。
<span class='line'> 70</span>  */</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="NAME">Drive.exist</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Const.FSO.DriveExists</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> 
<span class='line'> 75</span> </span><span class="COMM">// Prototypes of Drive</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="NAME">Drive.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 78</span>    * このドライブのAvailableSpaceを取得します。
<span class='line'> 79</span>    * @return {Number} このドライブのAvailableSpace
<span class='line'> 80</span>    */</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">  </span><span class="NAME">getAvailableSpace</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.AvailableSpace</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 85</span>    * このドライブのDriveLetterを取得します。
<span class='line'> 86</span>    * @return {String} このドライブのDriveLetter
<span class='line'> 87</span>    */</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">  </span><span class="NAME">getDriveLetter</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.DriveLetter</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 92</span>    * このドライブのDriveTypeを取得します。
<span class='line'> 93</span>    * @return {Number} このドライブのDriveType
<span class='line'> 94</span>    */</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">  </span><span class="NAME">getDriveType</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.DriveType</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 99</span>    * このドライブのFreeSpaceを取得します。
<span class='line'>100</span>    * @return {Number} このドライブのFreeSpace
<span class='line'>101</span>    */</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">  </span><span class="NAME">getFreeSpace</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.FreeSpace</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>106</span>    * このドライブのFileSystemを取得します。
<span class='line'>107</span>    * @return {String} このドライブのFileSystem
<span class='line'>108</span>    */</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">  </span><span class="NAME">getFileSystem</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.FileSystem</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>113</span>    * このドライブが使用可能かどうかを取得します。
<span class='line'>114</span>    * @return {String} このドライブが使用可能な場合true、そうでない場合はfalseを返します。
<span class='line'>115</span>    */</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">  </span><span class="NAME">isReady</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.IsReady</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>120</span>    * このドライブのSerialNumberを取得します。
<span class='line'>121</span>    * @return {String} このドライブのSerialNumber
<span class='line'>122</span>    */</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">  </span><span class="NAME">getSerialNumber</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.IsReady</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>127</span>    * このドライブのShareNameを取得します。
<span class='line'>128</span>    * @return {String} このドライブのShareName
<span class='line'>129</span>    */</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">  </span><span class="NAME">getShareName</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.ShareName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>134</span>    * このドライブのTotalSizeを取得します。
<span class='line'>135</span>    * @return {String} このドライブのTotalSize
<span class='line'>136</span>    */</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">  </span><span class="NAME">getTotalSize</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.TotalSize</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>141</span>    * このドライブのVolumeNameを取得します。
<span class='line'>142</span>    * @return {String} このドライブのVolumeName
<span class='line'>143</span>    */</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">  </span><span class="NAME">getVolumeName</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.driveObj.VolumeName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>147</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span></pre></body></html>